﻿using UnityEngine;
using System.Collections;

//------------------------------------------------------------
// shaco Framework
// Copyright © 2017-2021 chang.liu All rights reserved.
// Feedback: 449612236@qq.com
//------------------------------------------------------------
static public class shaco_ExtensionsLocalization
{
    static public void ChangeLanguage(this shaco.Base.ILocalization localization, SystemLanguage language, System.Action<SystemLanguage> callbackInitData)
    {
        callbackInitData(language);

        var allResourcesComponent = UnityEngine.GameObject.FindObjectsOfType<shaco.LocalizationComponent>();
        if (null == allResourcesComponent)
            return;

        for (int i = allResourcesComponent.Length - 1; i >= 0; --i)
        {
            allResourcesComponent[i].UpdateLocalization();
        }
    }

    static public void ChangeLanguage(this shaco.Base.Localization localization, SystemLanguage language, System.Action<SystemLanguage> callbackInitData)
    {
        shaco_ExtensionsLocalization.ChangeLanguage(localization as shaco.Base.ILocalization, language, callbackInitData);
    }
}